'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数

	const url = "https://open-sandbox.douyin.com/api/apps/v2/jscode2session"
	const data = {
	"appid": "填写自己的",
	"secret": "填写自己的",
	"anonymous_code": event.anonymousCode,
	"code": event.code,	
	}
	const login = await uniCloud.httpclient.request( url , {
			method: "POST",
			data: data,
			contentType: 'json', // 指定以application/json发送data内的数据
			dataType: 'json' // 指定返回值为json格式，自动进行parse

		})
	console.log('login : ', login)
	
	//返回数据给客户端
	return {
		login: login.data.data
	}
};